//
//  KCTool.h
//  Jade
//
//  Created by king on 16/4/7.
//  Copyright © 2016年 KC. All rights reserved.
//

#ifndef KCTool_h
#define KCTool_h


#ifdef __cplusplus
#define KCKIT_EXTERN		    extern "C" __attribute__((visibility ("default")))
#else
#define KCKIT_EXTERN	        extern __attribute__((visibility ("default")))
#endif

//**********************************************************************//

#define CY_PROPERTY(x) @property(nonatomic, x)
#define CY_PROPERTY_STRONG CY_PROPERTY(strong)
#define CY_PROPERTY_ASSIGN CY_PROPERTY(assign)
#define CY_PROPERTY_WEAK   CY_PROPERTY(weak)
#define CY_PROPERTY_COPY   CY_PROPERTY(copy)

//**********************************************************************//

//由角度转换弧度
#define kDegreesToRadian(x)      (M_PI * (x) / 180.0)
//由弧度转换角度
#define kRadianToDegrees(radian) (radian * 180.0) / (M_PI)

//**********************************************************************//

#define DEFAULTS                        [NSUserDefaults standardUserDefaults]

#define ShareApplication                [UIApplication sharedApplication]

#define ShareApplicationDelegate        ((AppDelegate *)[UIApplication sharedApplication].delegate)

#define NOTIFICATION_CENTER             [NSNotificationCenter defaultCenter]

#define ME_RED_BADGE                    [self.navigationController.tabBarController.tabBar.items objectAtIndex:3].badgeValue


//**********************************************************************//

#define R_G_B_COLOR(r,g,b)           [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:1]

#define R_G_B_A_COLOR(r,g,b,a)       [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:(a)]

#define CLEAR_COLOR                  [UIColor clearColor]

#define WHITE_COLOR                  [UIColor whiteColor]

#define COLOR_FOR_APP                 R_G_B_COLOR(62,54,51)

#define COLOR_FOR_APP_ALPHA           R_G_B_A_COLOR(62,54,51,0.6)

#define COLOR_FOR_BG                  R_G_B_COLOR(244,244,244)

#define COLOR_FOR_RED                 R_G_B_COLOR(246,54,83)

#define COLOR_FOR_GREEN               R_G_B_COLOR(152,232,96)

#define COLOR_FOR_RED_SELECT          R_G_B_COLOR(144,144,144)

#define COLOR_FOR_APP_TEXT            R_G_B_COLOR(152, 134, 112)

#define COLOR_FOR_SEL_TEXT            R_G_B_COLOR(255,238,198)

#define COLOR_FOR_LINE                R_G_B_COLOR(238,238,238)

#define COLOR_FOR_TEXT                R_G_B_COLOR(75,65,63)

#define COLOR_FOR_MESSAGE             R_G_B_COLOR(188,188,188)


#define COLOR_FOR_TAB_BACK            R_G_B_COLOR(236,235,243)

//**********************************************************************//

#define SCREEN_BOUNDS           [UIScreen mainScreen].bounds

#define SCREEN_WIDTH            [UIScreen mainScreen].bounds.size.width

#define SCREEN_HEIGHT           [UIScreen mainScreen].bounds.size.height

#define SCALE_SIZE(A)           SCREEN_WIDTH/A

#define IMAGE_HEIGHT            (SCREEN_WIDTH * 9/16)

#define DEVICE_VERSION          [UIDevice currentDevice].systemVersion.floatValue

#define APP_VERSION             [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"]
#define SYSTEM_FONT(A)          [UIFont fontWithName:@"STXingkai" size:A]

#define SYSTEM_BOLD_FONT(A)     [UIFont boldSystemFontOfSize:A]

#define TABLE_FRAME_H           CGRectMake(X_OFF_SET, Y_OFF_SET, SCREEN_WIDTH, SCREEN_HEIGHT - TAB_HEIGHT - NAV_HEIGHT)

#define TABLE_FRAME_S           CGRectMake(X_OFF_SET, NAV_HEIGHT, SCREEN_WIDTH, SCREEN_HEIGHT - TAB_HEIGHT - NAV_HEIGHT)

#define TABLE_FRAME_SS          CGRectMake(X_OFF_SET, NAV_HEIGHT, SCREEN_WIDTH, SCREEN_HEIGHT - NAV_HEIGHT - 40)

#define TABLE_FRAME             CGRectMake(X_OFF_SET, NAV_HEIGHT, SCREEN_WIDTH, SCREEN_HEIGHT - NAV_HEIGHT)

#define TABLE_FRAME_B           CGRectMake(X_OFF_SET, Y_OFF_SET, SCREEN_WIDTH, SCREEN_HEIGHT)

#define TABLE_STYLE_G           UITableViewStyleGrouped

#define TABLE_STYLE_P           UITableViewStylePlain

#define KC_KEY_WINDOW           [UIApplication sharedApplication].keyWindow

#define KC_ROOT_WINDOW          [UIApplication sharedApplication].keyWindow

#define STATE_HEIGHT                    [[UIApplication sharedApplication] statusBarFrame].size.height

#define IPHONE_X                        STATE_HEIGHT >= 44 ? 1 : 0


//**********************************************************************//

#ifdef DEBUG
#define KCLog(...) NSLog(__VA_ARGS__)
#else
#define KCLog(...)
#endif

#if TARGET_IPHONE_SIMULATOR
#define SIMULATOR 1
#elif TARGET_OS_IPHONE
#define SIMULATOR 0
#endif

#define KCLogFunc               KCLog(@"%s 第%d行",__func__,__LINE__)

#define WS(weakSelf)            __weak __typeof(&*self)weakSelf = self;

#define WEAK_SELF               __weak typeof(self) weakSelf = self

#define STRONG_SELF             __strong typeof(weakSelf) self = weakSelf

//**********************************************************************//

#define START_TAG              10
#define HOME_TAG               20


//**********************************************************************//


#define KCourse_Get_CourseList      0x01
#define KCourse_Get_MyCourseList    0x02


#endif /* KCTool_h */
